﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RealmMudLib.Managers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RealmMudLib.GameObjects.Base;

namespace RealmMudLib.Screens.Base
{
    public class GameScreen
    {
        public ScreenManager Manager { get; set; }
        public SpriteBatch spriteBatch { get; set; }
        public List<GameObject> gameObjects { get; set; }

        public GameScreen(ScreenManager manager)
        {
            this.Manager = manager;
            this.gameObjects = new List<GameObject>();
        }
        public virtual void LoadContent()
        {
        }
        public virtual void UnloadContent()
        {
        }
        public virtual void Update(GameTime gameTime)
        {

            foreach (GameObject go in gameObjects)
            {
                go.Update(gameTime);

            }
        }
        public virtual void Draw(GameTime gameTime)
        {
            spriteBatch = new SpriteBatch(Manager.BaseGame.GraphicsDevice);
            //Manager.BaseGame.GraphicsDevice.Clear(Color.Black);

            // Draw all our objects
            foreach (GameObject go in gameObjects)
            {
                go.Draw(gameTime);
            }
        }
        public bool AddGameObject(GameObject gameObject)
        {
            try
            {
                this.gameObjects.Add(gameObject);
                return true;
            }
            catch { return false; }
        }
    }
}
